package com.jeecg.graduation;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.jeecgframework.core.interceptors.DateConvertEditor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.servlet.ModelAndView;


/**
 * @author Debenson
 * @since 0.1
 */
@ControllerAdvice
public abstract class SBaseController {
  private static final Logger logger = LoggerFactory.getLogger(SBaseController.class);
  public static final String VIEW_BASE_PATH = "com/graduation/";

  @Autowired
  protected ApplicationContext appCxt;
  @Autowired
  protected HttpServletRequest request;
  /**
   * 显示微信页面
   * 
   * @param view
   * @return
   */
  public ModelAndView showView(String view) {
    String url = VIEW_BASE_PATH  + view;
    return new ModelAndView(url);
  }




  /**
   * 将前台传递过来的日期格式的字符串，自动转化为Date类型
   * 
   * @param binder
   */
  @InitBinder
  public void initBinder(ServletRequestDataBinder binder) {
    binder.registerCustomEditor(Date.class, new DateConvertEditor());
  }


}
